import Vue from 'vue'
import Router from 'vue-router'
import Login from "../components/Login.vue";
import Register from "../components/Register.vue";
import Home from "../components/Home.vue";  // 确保正确导入Home组件
import Toilet from '../components/Toilet.vue'
import HomeContent from '../components/HomeContent.vue'  // 导入HomeContent组件

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      redirect: '/login'  // 添加重定向到/login
    },
    {
      path: '/login',
      name: 'Login',
      component: Login
    },
    {
      path: '/register',
      name: 'Register',
      component: Register
    },
    {
      path: '/home',
      name: 'Home',
      component: Home,
      children: [
        {
          path: '',  // 默认子路由
          name: 'HomeContent',
          component: HomeContent
        },
        {
          path: 'toilet',  // 注意这里不要加斜杠
          name: 'Toilet',
          component: Toilet,
          meta: {
            title: '公厕管理'
          }
        }
      ]
    }
  ]
})
